/**
 * 
 */
package com.thor.palmmall.rest.tenant.converter;

import java.util.ArrayList;

import org.springframework.core.convert.converter.Converter;

import com.thor.commons.entity.KV;
import com.thor.palmmall.rest.tenant.ATenantQueryParam;
import com.thor.palmmall.spi.tenant.STenantQueryParam;

/**
 * @author NuoSa
 *
 * @since 1.0
 */
public class STenantQueryParamConverter implements Converter<ATenantQueryParam, STenantQueryParam> {

  public static STenantQueryParamConverter getInstance() {
    if (instance == null)
      instance = new STenantQueryParamConverter();
    return instance;
  }

  private static STenantQueryParamConverter instance;

  private STenantQueryParamConverter() {
  }

  @Override
  public STenantQueryParam convert(ATenantQueryParam source) {
    if (source == null) {
      return null;
    }
    STenantQueryParam target = new STenantQueryParam();
    target.setKeyword(source.getKeyword());;
    target.setOrder(source.getOrder());
    target.setPage(source.getPage());
    target.setPageSize(source.getPageSize());
    target.setUserGroups(new ArrayList<KV>());
    target.getUserGroups().addAll(source.getUserGroups());
    return target;
  }

}
